<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>随即更换背景图</title>
</head>
<style>
    div{
        width: 1536px;
        height: 864px;
        background-image: url("./JS案例需要的素材/backageImg_1.png");
    }
</style>
<body>
<div>

</div>
</body>
<script>
    function a(m,n){
        return Math.floor(Math.random()*(n-m+1)+m)
    }
    var random=a(1,4)
    var elementsByTagName = document.getElementsByTagName("div");
    elementsByTagName[0].style.backgroundImage="url('./JS案例需要的素材/backageImg_"+random+".png')"

</script>
</html>